package com.hospital.utils;

import java.util.HashMap;
import java.util.Map;

import com.hospital.R;

public class MainUtils {
	public final static int PAGE_RID_NONE = -1;
	private final static String TAG = "MainUtils";
	private final static String PAGE_ID_FRM_PATIENT_LIST = "01";
	private final static String PAGE_ID_NI_VITAL_SIGN = "20";
	private final static String PAGE_ID_NI_DAILY_CARE = "21";
	private final static String PAGE_ID_NI_RECORDS = "22";
	private final static String PAGE_ID_NI_EVALUATION = "23";
	private final static String PAGE_ID_NI_EVALUATION_ENTRY = "24";
	private final static String PAGE_ID_OI_INSPECTION = "30";
	private final static String PAGE_ID_OI_CHECK = "31";
	private final static String PAGE_ID_OI_DETAILS = "32";
	private final static String PAGE_ID_OI_SURGERY = "33";
	private final static String PAGE_ID_OI_CONSULTATION = "34";
	private final static String PAGE_ID_OI_HEALTH_EDUCATION = "35";
	private final static String PAGE_ID_SR_BASIC_CARE = "40";
	private final static String PAGE_ID_SR_ADMISSION_DISCHARGE = "41";
	private final static String PAGE_ID_SR_WORKLOAD = "42";
	private final static String PAGE_ID_SR_QUALITY = "43";
	private final static String PAGE_ID_SR_BODY_TEMPERATURE = "44";
	private final static String PAGE_ID_SR_TEMPERATURE_CHART = "45";
	private final static String PAGE_ID_AM_ORDER_LIST = "10";
	private final static String PAGE_ID_AM_EXECUTIVE_ORDERS = "11";
	private final static String PAGE_ID_AM_PRESCRIPTION = "12";
	private final static String PAGE_ID_AM_SCAN_WRISTBAND = "13";
	private final static String PAGE_ID_AM_SCAN_MEDICAL_PACKAGE = "14";
	private final static String PAGE_ID_AM_ORDER_SPLITTING = "15";
	private final static String PAGE_ID_SS_REMINDER = "";
	private final static String PAGE_ID_SS_DISPLAY = "";
	private final static String PAGE_ID_SS_VITAL_SIGN_ITEM_LIST = "50";
	private final static String PAGE_ID_SS_SIGN_ITEM_MAINTENANCE = "51";
	private final static String PAGE_ID_SS_SPLIT_ORDER_TYPES = "52";
	private final static String PAGE_ID_SS_PRINTER = "53";
	private final static String PAGE_ID_SS_USER_PERMISSIONS = "54";
	private final static String PAGE_ID_SS_NURSING_GRADE = "55";
	private final static String PAGE_ID_SS_BEDSIDE_CARD = "56";
	private final static String PAGE_ID_SS_EVALUATION_ITEMS = "57";
	private final static String PAGE_ID_SS_NURSING_ITEMS = "58";

	private static final String[] PAGE_ID_TABLE = { PAGE_ID_FRM_PATIENT_LIST,
			PAGE_ID_NI_VITAL_SIGN, PAGE_ID_NI_DAILY_CARE, PAGE_ID_NI_RECORDS,
			PAGE_ID_NI_EVALUATION, PAGE_ID_NI_EVALUATION_ENTRY,
			PAGE_ID_OI_INSPECTION, PAGE_ID_OI_CHECK, PAGE_ID_OI_DETAILS,
			PAGE_ID_OI_SURGERY, PAGE_ID_OI_CONSULTATION,
			PAGE_ID_OI_HEALTH_EDUCATION, PAGE_ID_SR_BASIC_CARE,
			PAGE_ID_SR_ADMISSION_DISCHARGE, PAGE_ID_SR_WORKLOAD,
			PAGE_ID_SR_QUALITY, PAGE_ID_SR_BODY_TEMPERATURE,
			PAGE_ID_SR_TEMPERATURE_CHART, PAGE_ID_AM_ORDER_LIST,
			PAGE_ID_AM_EXECUTIVE_ORDERS, PAGE_ID_AM_PRESCRIPTION,
			PAGE_ID_AM_SCAN_WRISTBAND, PAGE_ID_AM_SCAN_MEDICAL_PACKAGE,
			PAGE_ID_AM_ORDER_SPLITTING, PAGE_ID_SS_REMINDER,
			PAGE_ID_SS_DISPLAY, PAGE_ID_SS_VITAL_SIGN_ITEM_LIST,
			PAGE_ID_SS_SIGN_ITEM_MAINTENANCE, PAGE_ID_SS_SPLIT_ORDER_TYPES,
			PAGE_ID_SS_PRINTER, PAGE_ID_SS_USER_PERMISSIONS,
			PAGE_ID_SS_NURSING_GRADE, PAGE_ID_SS_BEDSIDE_CARD,
			PAGE_ID_SS_EVALUATION_ITEMS, PAGE_ID_SS_NURSING_ITEMS };

	private static final int[] RID_TABLE = { R.layout.sick_list_layout,
			PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE,
			PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE,
			PAGE_RID_NONE, PAGE_RID_NONE, R.layout.health_education,
			PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE,
			PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE,
			PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE,
			PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE,
			PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE,
			PAGE_RID_NONE, PAGE_RID_NONE, PAGE_RID_NONE

	};
	private static Map<String, Integer> PAGE_RID_TABLE;

	private static void init() {
		if (PAGE_RID_TABLE == null) {
			PAGE_RID_TABLE = new HashMap<String, Integer>();
			int count = PAGE_ID_TABLE.length;
			int rid;
			for (int i = 0; i < count; i++) {
				LogUtils.i(TAG, "MainUtils i = " + i);
				try {
					rid = RID_TABLE[i];
				} catch (Exception e) {
					e.printStackTrace();
					rid = PAGE_RID_NONE;
				}
				PAGE_RID_TABLE.put(PAGE_ID_TABLE[i], new Integer(rid));
			}
		}
	}

	public static String genKey(int groupPosition, int childPosition) {
		String key = String.valueOf(groupPosition) + childPosition;
		return key;
	}

	public static int getPageRid(String key) {
		init();
		if (PAGE_RID_TABLE != null) {
			if (PAGE_RID_TABLE.containsKey(key)) {
				return PAGE_RID_TABLE.get(key);
			}
		}
		return PAGE_RID_NONE;
	}
}
